const router = require('koa-router')()
const controller = require('../controllers')
const koaBody = require('koa-body')


router.get('/', async (ctx, next) => {
  await ctx.render('index', {
    title: 'Hello Koa 2!'
  })
})

router.get('string', async (ctx, next) => {
  ctx.body = 'koa2 string'
})

router.post('json', async (ctx, next) => {
  console.log(ctx.request.body)
  ctx.body = {
    title: 'koa2 json'
  }
})

router.post('login', controller.user.login)

router.post('work/upload', koaBody({multipart:true, formidable: {maxFieldsSize: 52428800}}), controller.work.upload)
router.get('work/files_list', controller.work.files)

module.exports = router
